package com.example.myviewdemo;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.Size;
import android.view.View;

/**
 * TODO: document your custom view class.
 */
public class MyView extends View {
    private float mPts[];
    private static final int SIZE = 300;
    private static final int SEGS = 32;
    private static final int X = 0;
    private static final int Y = 1;

    public MyView(Context context) {
        super(context);
        buildPoints();

    }
    private void buildPoints(){
        final int ptCounts = (SEGS + 1) * 2;
        mPts = new float[ptCounts * 2];
        float value = 0;
        final float delta = SIZE / SEGS;
        for (int i=0;i<+SEGS;i++){
            mPts[i * 4 + X] = SIZE - value;
            mPts[i * 4 + Y] = 0;
            mPts[i * 4 + X + 2] = 0;
            mPts[i * 4 + Y + 2] = value;
            value += delta;

        }
    }


    private void init(AttributeSet attrs, int defStyle) {

    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.translate(10, 10);
        canvas.drawColor(Color.WHITE);
        Paint paint = new Paint();
        paint.setColor(Color.RED);
        paint.setStrokeWidth(0);
        canvas.drawLines(mPts,paint);
        Paint paint1 = new Paint();
        paint1.setColor(Color.rgb(251,114,153));
        RectF rect= new RectF(50,50,1000,1000);
        canvas.drawRoundRect(rect,60,60,paint1);
    }
}


